var a = getApp();

Page({
    data: {
        users: null,
        teams: null,
        dynamics: null,
        key: "",
        platform: "ios"
    },
    keyInput: function(a) {
        var t = a.detail.value;
        this.setData({
            key: t
        }), console.log(this.data.key);
    },
    clickSearch: function(a) {
        console.log(this.data.key), this.loadData(this.data.key, !0);
    },
    loadData: function(t, e) {
        var o = this;
        if (e) o.data.pageNo = 1; else if (o.data.total == o.data.dynamics.length) return;
        a.network.post({
            url: a.url.hunyuCycleSearch,
            params: {
                pageNo: o.data.pageNo,
                pageSize: 20,
                key: t
            },
            before: function() {
                wx.showNavigationBarLoading();
            },
            success: function(t) {
                if (1 == t.data.result) {
                    if (e) {
                        var n = t.data.data.dynamics, s = t.data.data.users, i = t.data.data.teams;
                        o.setData({
                            total: t.data.data.total,
                            dynamics: n,
                            users: s,
                            teams: i
                        });
                    } else n = (n = o.data.dynamics).concat(t.data.data.dynamics), o.setData({
                        total: t.data.data.total,
                        dynamics: n
                    });
                    var c = o.data.pageNo + 1;
                    o.setData({
                        pageNo: c
                    });
                } else a.util.showToast(t.data.message);
            },
            fail: function() {
                a.util.showToast("获取数据失败");
            },
            complete: function() {
                wx.hideNavigationBarLoading(), wx.stopPullDownRefresh();
            }
        });
    },
    tapAvatar: function(t) {
        var e = t.currentTarget.dataset.accesstoken;
        a.util.navToUserHome(e);
    },
    tapLogo: function(t) {
        var e = t.currentTarget.dataset.teamid;
        a.util.navToTeamHome(e);
    },
    onLoad: function(a) {
        var t = wx.getSystemInfoSync();
        this.setData({
            platform: t.platform
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.loadData(this.data.key, !1);
    },
    onShareAppMessage: function() {
        return {
            title: "‘婚语’婚礼人工具",
            path: "/pages/schedule/schedule",
            success: function(a) {},
            fail: function(a) {}
        };
    }
});